from django33_ninja_extra import NinjaExtraAPI
from django33_ninja_extra import api_controller, http_get

api = NinjaExtraAPI()


# 服务类
class UserService:
    def get_user_details(self, user_id: int):
        return {"user_id": user_id, "status": "active"}


# 依赖注入
@api_controller('/users', tags=['Users'])
class UserController:
    def __init__(self, user_service: UserService):
        self.user_service = user_service

    @http_get('/{user_id}')
    def get_user(self, user_id: int):
        return self.user_service.get_user_details(user_id)


# 注册控制器
api.register_controllers(UserController)
